package Chapter05.Automobilemanagement;

import java.util.Scanner;

public class RentMgrSys {
    public static void main(String[] args) {
        CarBusiness car = new CarBusiness();
        System.out.println("金路至尊租赁有限公司欢迎您，请致电999999洽谈相关租赁任务");
        while (true) {
            int ch = 0;
            boolean isExit=false;
            int carnum = car.getCarnum();
            System.out.println("本公司现有" + carnum + "辆车可租");
            System.out.println("1：查看车辆情况 2：租赁 3：还车 4：报废 5：采购新车 6：查看租赁记录 9：退出");
            Scanner input = new Scanner(System.in);
            ch = input.nextInt();
            switch (ch) {
                case 1:
                    car.displayinformation();
                    break;
                case 2:
                    if (carnum == 0) {
                        System.out.println("现在没有车");
                    } else {
                        System.out.println("请输入要租车辆的类型（轿车/客车）");
                        String type = input.next();
                        int counts = car.showCarcount(type);
                        if (counts == 0) {
                            System.out.println("当前类型无车可租");
                            break;
                        } else {
                            System.out.println("当前类型车有" + counts + "辆");
                        }
                        System.out.println("现有车辆信息如下");
                        car.showCar(type);
                        System.out.println("请选择想租赁车的车牌号：");
                        String plate = input.next();
                        boolean flag = car.rentCar1(plate);
                        if (flag == false) {
                            break;
                        }
                        System.out.println("请选择想租赁车的天数：");
                        int day = input.nextInt();
                        car.rentCar2(plate, day);
                        System.out.println("祝您用车愉快！");
                        break;
                    }
                    break;
                case 3:
                    System.out.println("请输入车牌号:");
                    String plate1 = input.next();
                    boolean flag = car.Returnthecar(plate1);
                    if (false == true) {
                        System.out.println("还车成功，下次继续合作");
                    }
                    break;
                case 4:
                    System.out.println("请输入报废的车辆车牌号");
                    String plate2 = input.next();
                    car.scrap(plate2);
                    break;
                case 5:
                    System.out.println("请输入你购买的新车的类型(轿车/客车)");
                    while (true) {
                        String type = input.next();
                        if (type.equals("轿车") || type.equals("客车")) {
                            System.out.println("请输入你想购买的品牌:");
                            String pinpai = input.next();
                            System.out.println("请输入你想购买的车牌:");
                            String chepai = input.next();
                            System.out.println("请设定你新车的租金:");
                            int zhujin = input.nextInt();
                            System.out.println("请输入你新车的座位数:");
                            int zhuoweis = input.nextInt();
                            boolean state=true;
                            car.addCar(pinpai, chepai, type, zhujin, zhuoweis,state);
                            break;
                        } else {
                            System.out.println("输入错误，请再次输入！");
                        }
                    }
                case 6:
                    break;
                case 9:
                    System.out.println("欢迎下次光临！");
                    isExit = true;
                    break;
                default:
                    System.out.println("输入错误");
                    break;
            }
        }
    }
}
